import React, { lazy } from 'react'

// 二
const Home = lazy(() => import('../pages/Home'))
const Login = lazy(() => import('../pages/Login'))
const Err401 = lazy(() => import('../pages/ErrPage/401'))

// 一
const Layout = lazy(() => import('../layout'))

// 三
const Check = lazy(() => import('../pages/Check'))
const Add = lazy(() => import('../pages/Add'))
const AddUser = lazy(() => import('../pages/AddUser'))

export const menuList = [
    {
        path: '/home/check',
        element: <Check />,
        key: 'check',
        title: '查看试题',
        auth: '100'
    },
    {
        path: '/home/add',
        element: <Add />,
        key: 'add',
        title: '添加试题',
        auth: '101'
    },
    {
        path: '/home/addUser',
        element: <AddUser />,
        key: 'addUser',
        title: '添加用户',
        auth: '102'
    }
]

const routes = [
    {
        // 通过正则匹配路由路径 并非全匹配 只要有一项符合条件 就匹配
        from: '/',
        to: '/home'
    },
    {
        path: "/",
        element: <Layout />, // 公共页面
        children: [
            {
                path: '/home',
                element: <Home />,
                children: menuList
            },
            {
                path: '/login',
                element: <Login />
            },
            {
                path: '/401',
                element: <Err401/>
            }
        ]
    },
]

export default routes
